package com.itdfq.delay.message.listen;

import com.alibaba.fastjson.JSON;
import com.itdfq.delay.constant.RabbitMqConstant;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import com.rabbitmq.client.Channel;

/**
 * @Author: QianMo
 * @Date: 2021/10/19 18:50
 * @Description:
 */
@Component
@Slf4j
public class MessageListen {

//    @RabbitListener(bindings = @QueueBinding(
//            value = @Queue(value = RabbitMqConstant.DELAY_QUEUE, durable = "true"),
//            exchange = @Exchange(value = RabbitMqConstant.DELAY_EXCHANGE),
//            key = RabbitMqConstant.DELAY_ROUTING_KEY
//    ))

    @RabbitListener(queues = RabbitMqConstant.DELAY_QUEUE)
    public void infoConsumption(Message message, Channel channel) throws Exception {
        log.info("收到延时队列的信息信息:{}", JSON.toJSONString(message));
        log.info("然后进行一系列逻辑处理 Thanks♪(･ω･)ﾉ");
//        channel.basicNack(message.getMessageProperties().getDeliveryTag(),false,true);
    }
}
